package com.kedacom.freedomLabel.utils;

import java.math.BigDecimal;

public class DistenUtils {

    /**
     * 计算视比重
     *
     * @param weight 当前称重的重量
     * @return
     */
    public static BigDecimal getDistenty(BigDecimal weight, BigDecimal cupEmptyWright, BigDecimal cupVolumn) {
        BigDecimal bigDecimal = weight.subtract(cupEmptyWright).divide(cupVolumn, 2, BigDecimal.ROUND_HALF_UP);
        return bigDecimal;
    }


    public static boolean isEquals(BigDecimal a, BigDecimal b) {
        if (a.compareTo(b) == 0) {
            return true;
        } else {
            return false;
        }
    }

    /**
     * 是否大于上线
     */
    public static boolean isMoreThanMost(BigDecimal weight, BigDecimal most) {
        if (weight.compareTo(most) == 1) {
            return true;
        }
        return false;
    }

    /**
     * 是否小于等于一个数字
     */
    public static boolean isEuqlaOrLow(BigDecimal curNum, BigDecimal toNum) {
        if (curNum.compareTo(toNum) < 1) {
            return true;
        } else {
            return false;
        }
    }

    /**
     * 是否小于下限
     */
    public static boolean isLowerThanMin(BigDecimal weight, BigDecimal min) {

        if (weight.compareTo(min) == -1) {
            return true;
        }
        return false;
    }

    /**
     * 是否大于下线，小于上线
     */
    public static int isMoreMinLowMost(BigDecimal weight, BigDecimal min, BigDecimal most) {
        if (weight.compareTo(min) > -1 && weight.compareTo(most) < 1) {
            //正常
            return 1;
        } else if (weight.compareTo(min) == -1) {
            //小于最小
            return -1;
        } else if (weight.compareTo(most) == 1) {
            //大于最大
            return 0;
        }
        //非正常状态
        return 2;
    }


}
